Skip to content

Conversation

VincentLanglet
Copy link
Contributor

@VincentLanglet VincentLanglet commented Aug 4, 2025

@VincentLanglet VincentLanglet marked this pull request as ready for review August 4, 2025 08:53
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@ondrejmirtes
Copy link
Member

I feel like we'd need a similar fix for Scope manipulation in NodeScopeResolver. There this situation is detected by instanceof ErrorType which sometimes fails.

Try adding assertType tests around this code.

@VincentLanglet
Copy link
Contributor Author

Try adding assertType tests around this code.

Added.

We get,

assertType('mixed', $data);
$data[] = 1;
assertType('mixed', $data);

function (): void {
	assertType('*ERROR*', $data);
	$data[] = 1;
	assertType('array{1}', $data);
};

@ondrejmirtes
Copy link
Member

We should get rid of instanceof ErrorType in NodeScopeResolver. It leads to these problems: https://phpstan.org/r/a2ab0fbe-4741-4ab3-8d8e-51d9d29a91ac

@ondrejmirtes
Copy link
Member

And regarding:

We get,

That's perfect! 👍

@VincentLanglet
Copy link
Contributor Author

VincentLanglet commented Aug 4, 2025

We should get rid of instanceof ErrorType in NodeScopeResolver. It leads to these problems: phpstan.org/r/a2ab0fbe-4741-4ab3-8d8e-51d9d29a91ac

I get

$a = $foo->doFoo();
		assertType('*ERROR*', $a);
		$a[] = 5;
		assertType('mixed', $a);

now

@ondrejmirtes
Copy link
Member

Look at the issue bot, this also fixes phpstan/phpstan#7286 (your issue) and also maybe phpstan/phpstan#3803. Please add regression tests for them.

@VincentLanglet
Copy link
Contributor Author

Look at the issue bot, this also fixes phpstan/phpstan#7286 (your issue) and also maybe phpstan/phpstan#3803. Please add regression tests for them.

Indeed, both are fixed. Nice, I added two non regressions tests then.

@ondrejmirtes ondrejmirtes merged commit cabe851 into phpstan:2.1.x Sep 2, 2025
449 of 454 checks passed
@ondrejmirtes
Copy link
Member

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants